
export default {
    namespaced: true,
    state: {
      sysUser: {name:"小明"},
      sysCode: { aaa: "110", bbb: "120" }
    },
   
    mutations: { //同步方法代替构造器
      setSysUser(state, user) {
        state.sysUser = user;
      },
      setSysCode(state, code) {
        state.sysCode = code;
      },
      setName(state,name) {
          state.sysUser.name = name
      }
    },
   
    actions: { //异步方法->外部使用的方法
      userLoad(context, code) {
        context.commit("setSysUser", code);//间接调用mutations
      },
      codeLoad({ commit }, code) {
        commit("setSysCode", code);
      },
      nameLoad({commit},name) {
          commit("setName",name)
      }
    }
  };